package aad.storyboard.model;

import java.util.ArrayList;

import android.graphics.Bitmap;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;

public class CrossFadeAnimation extends Animation{
	
	private static Paint mForeGroundPaint;  
    private static Paint mBackGroundPaint;   
   
    private static int foregrndalpha = 255;  
    private static int backgrndalpha = 0;    
    
    private static Image inextCharacter;  
    private static Image icurrentCharacter;  
   
    public CrossFadeAnimation(int startTime,int duration, Image current, Image next)  
    {  
    	super(duration,startTime);
    	    	
    	mForeGroundPaint = new Paint();  
    	mBackGroundPaint = new Paint();  
     
      /* assign the background, foreground images */     
    	inextCharacter=next;
    	icurrentCharacter=current;
    
    	inextCharacter.setPaint(mBackGroundPaint);
    	icurrentCharacter.setPaint(mForeGroundPaint);    	    	
    
     }  
    
	@Override
	public void animate() {	
	         
	        if(foregrndalpha > 0 )  
	        {	         
	          foregrndalpha -= 5;  
	          backgrndalpha += 5;
	          mForeGroundPaint.setAlpha(foregrndalpha);  
		      mBackGroundPaint.setAlpha(backgrndalpha);		      
	         } 
	    	
	}

	//change object back again
	public void undo() {		
		mForeGroundPaint.setAlpha(255);  
	    mBackGroundPaint.setAlpha(0);
	}

	//is called if the animation is stopped such that undo can be done properly
	public void adjustParameters() {
		// TODO Auto-generated method stub
		
	}
	      

}
